package org.moyrax.nereyda.services.events
{
	import org.moyrax.nereyda.services.template.IServiceEvent;
	import org.moyrax.nereyda.services.template.IServiceObject;
	
	import flash.events.Event;
	
	/**
	 * Se desencadenará cuando haya llegado la
	 * respuesta de algún servicio del servidor.
	 */
	public class ServiceEvent extends Event implements IServiceEvent
	{
		public static const REQUEST_FAIL    :String = "RequestFailEvent";
		public static const REQUEST_SUCCESS :String = "RequestSuccessEvent";
		public static const UNHANDLED_ERROR :String = "UnhandledErrorEvent";
		
		[Bindable]
		public var result : IServiceObject = null;

		[Bindable]
		public var endpointName : String = null;
		
		[Bindable]
		public var eventName : String = null;

		[Bindable]
		public var rawData : String = null;

		public function ServiceEvent( response:IServiceObject ):void
		{
			this.result = response;
			
			super( this.type );
		}

		override public function get type() :String
		{
			return( this.eventName );
		}
		
		public function set type( value:String ):void
		{
			this.eventName = value;
		}

		override public function clone():Event
		{
			return( new ServiceEvent( this.result ) );
		}
	}
}